import QtQuick 1.1
import com.nokia.meego 1.0

PageStackWindow {
    //page stack prozor u kojem imamo pageove
    //pogle: http://doc.qt.nokia.com/qt-components-symbian-1.0/qt-components-pages-and-navigation-overview.html

    id: appWindow

    initialPage: menuPage //to nam je page s izbornikom


    QueryDialog{

    }

    MenuPage {
        id: menuPage

        property variant helloDialog

        Component.onCompleted: {
            if (qmlHandler.firstTime()){
                qmlHandler.createTables()

                qmlHandler.refreshLanguages()

                var component = Qt.createComponent("HelloDialog.qml")
                helloDialog = component.createObject(menuPage)
                helloDialog.accepted.connect(createTables)
                helloDialog.rejected.connect(refreshAllModels)
                helloDialog.open()

            }else{
                refreshAllModels()
            }
        }

        function createTables(){
            qmlHandler.createExampleDatabase()
            helloDialog.destroy()
            refreshAllModels()
        }

        function refreshAllModels(){
            qmlHandler.refreshAllLists()
            qmlHandler.refreshGroups()
            qmlHandler.refreshUnits()
            qmlHandler.refreshItems(-1,-1)

        }
    }


}
